What is ActionResult in asp.net MVC? Explain its type.
What is ActionResult in asp.net MVC? Explain its Type.
The information provided here is part of Export Import Training online After the exploration of information technology, the world is on our finger tips to get any piece of information. However when I went through different subjects on the web, I realized, like every thing in society, internet also carries the good and the bad. I was surprised to note that, I could not find any good quality free tutorial program to enter in a good business especially in
Steilla Mitchel
11-Mar-2022Action Results in ASP.Net MVC :
When we create a controller in asp.net mvc then a ActionResult method is automatically generated named as Index that returns a view(). In asp.net mvc an ActionResult is an Abstract class and ActionResult is a return type of controller method. Each ActionResult return different type of result. If we need to return an image then we need use FileResult method which is built-in method in asp.net mvc.
Types of ActionResult in MVC:
There are many types of ActionResults that are used in mvc given as below,
1- ContentResult:
It returns user type content and http content type like text.
return Content('This is my content result');2- ViewResult:
This return type is used to return webpage from action method or in short term it return a view as a Webpage.
return View('Index');3- RedirectToRouteResult:
It is used to redirect to another controller and action method.
4- RedirectResult:
It return to a specific action method based on URL.
return Redirect('/Home/index');5- PartialViewResult:
It return a partial view to the response or It returns a part of a view that will rendered in another view.
public PartialViewResult PartialViewExp() { return PartialView('Login'); }6- jsonResult:
This return type is used to return Json message.
7- javascriptResult:
This return type is used to return javascript code that is run on client's browser.
8- EmptyResult:
This is returns a result that does nothing.
9- FileResult:
This return type is use to returns binary file content to the response.